{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1.2300007 2.67     ]\n",
      " [1.45      6.       ]]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "data6 =[[1.2300007, 2.670],[1.450, 6.000]]\n",
    "arr6 = np.array(data6, np.float32)\n",
    "print(arr6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1.23, 2.67],\n",
       "       [1.45, 6.  ]], dtype=float16)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "temp = arr6.astype(np.float16)\n",
    "temp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2],\n",
       "       [1, 6]], dtype=int16)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "temp2 = arr6.astype(np.int16)\n",
    "temp2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1.23 2.67]\n",
      " [1.45 6.  ]]\n"
     ]
    }
   ],
   "source": [
    "np.set_printoptions(precision=4)\n",
    "print(arr6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.71777054, 0.97061857],\n",
       "       [0.45501533, 0.18731583],\n",
       "       [0.1980577 , 0.05762309]])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr_rand0 = arr_rand0 = np.random.rand(3, 2)\n",
    "arr_rand0\n",
    "arr_rand0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.82946668, 0.79152881, 0.69187278, 0.20022735, 0.9976645 ,\n",
       "       0.61862588, 0.36731511, 0.43950153, 0.99229453, 0.70048764])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rand1 = np.random.rand(10)\n",
    "rand1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[  6.1350018 ,  12.01494696],\n",
       "       [-10.37877709,  -7.87915373],\n",
       "       [ 16.76324786,  -0.75853861]])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 产生一个大小为3×2，符合均值为5，标准差为10的正态分布的数组\n",
    "arr_rand3 = np.random.normal(5, 10, (3, 2))\n",
    "arr_rand3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.43950153 0.82946668 0.9976645 ]\n"
     ]
    }
   ],
   "source": [
    "sample = np.random.choice(rand1,3)\n",
    "print(sample)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([10.34775905, 10.85605751, 10.74482374, 10.67176526, 10.49344005,\n",
       "       10.17603585, 10.03445645, 10.86320425, 10.32265283, 10.12734125])"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rand2 = np.random.rand(10)\n",
    "rand2 += 10\n",
    "rand2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[6.2 3.2 5.2 4.8 6.  6.  4.8 4.  6.4 3.4]\n"
     ]
    }
   ],
   "source": [
    "scores = np.random.randint(1,10,(10,7))\n",
    "score = (np.sum(scores,axis=1)-np.max(scores,axis=1)-np.min(scores,axis=1))/5\n",
    "print(score)"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "11f1dc213e07634baa4c5c321dec03c05dafae643c50f20e6d1a492290c05dc2"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 64-bit",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
